<template>
  <div>
    <img alt="Vue logo" src="./assets/logo.png" />
    <HelloWorld msg="Welcome to Your Vue.js App" />
    <div id="app">
      {{ name }} {{ name2 }}
      <p>{{ age }}</p>
      <button @click="plusOne()">+</button>
    </div>
  </div>
</template>

<script>
import { ref, watch, computed, h } from "vue";
import HelloWorld from "./components/HelloWorld.vue";

export default {
  components: {
    HelloWorld,
  },
  data: function() {
    return {
      message: "XXXX",
      name: "xiaosan",
    };
  },
  // 有人说有这个方法，实际这个方法不会被调用
  // setUp: function () {
  //   console.log("setUp 创建前状态===============》");
  // },
  setup() {
    const name2 = ref("小四");
    const age = ref(18);
    function plusOne() {
      age.value++; //想改变值或获取值 必须.value
    }
    return {
      //必须返回 模板中才能使用
      name2: name2,
      age,
      plusOne,
    };
  },

  beforeCreate: function() {
    console.log("beforeCreate 创建前状态===============》");
  },
  created: function() {
    console.log("created 创建完毕状态===============》");
  },
  beforeMount: function() {
    console.log("beforeMount 挂载前状态===============》");
  },
  mounted: function() {
    console.log("mounted 挂载结束状态===============》");
  },
  beforeUpdate: function() {
    console.log("beforeUpdate 更新前状态===============》");
  },
  updated: function() {
    console.log("updated 更新完成状态===============》");
  },
  // beforeDestroy: function () {
  //   console.log("beforeDestroy 销毁前状态===============》");
  // },
  // destroyed: function () {
  //   console.log("destroyed 销毁完成状态===============》");
  // },
  methods: {
    test() {},
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
